
#Title[gQ]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_mokou.png"; 
    // ʒu
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 128;
	let Step2=false;
	let wIni=60;
let TimeCounter=60*60;
let StandardTimeCounter=TimeCounter;
let ColorRed=255;
let ColorGreen=0;
let ColorBlue=0;
    @Initialize {
	SetCommonData("BossLastAttackColor",[255,100,0]);
	SetCommonData("BossLastAttack",true);
	SetShotAutoDeleteClip(4,4,4,4);
	LoadUserShotData(GetCurrentScriptDirectory~".\..\img\shot_All.txt");
        SetTimer(TimeCounter/60);
        SetLife(4600);
 LoadGraphic(GetCurrentScriptDirectory~"..\img\CircleEffect.png");
	InitializeAction();
	SetEnemyMarker(true);
        TMainGrobal;
    }

    @MainLoop {
	BulletNum=GetEnemyShotCount;
	TimeCounter-=1;
        yield;
    }

    @DrawLoop {
	DrawBoss( imgBoss );
    }

    @Finalize {
		if(!IsTimeOut)
		{
		SetCommonData("DeleteBulletNum",BulletNum);
		SetCommonData("DeleteBulletX",GetX);
		SetCommonData("DeleteBulletY",GetY);
		}

	SetCommonData("VanishSignal",false);
	SetCommonData("TimeBonus",TimeCounter/StandardTimeCounter);
	SetCommonData("BossRate",30000);
    }

    // C^XN
task TMainGrobal
{
	yield;
	Wing;
	GetDamege;
	OutDamageRateZero;
	Collision;
	//Lissajous(0,64,255);
	BossShadowAnimation(imgBoss,0,255,100,0);
	standBy;
	alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
	case("Moderate")
	{
	shotM;
	}
	case("Extream")
	{
	shotE;
	}
	case("Apocalypse")
	{
	shotA;
	}
}

task Collision
{
	wait(60);

	loop
	{
        SetCollisionA(GetX, GetY, 48);
        SetCollisionA(GetX+88, GetY, 48);
        SetCollisionA(GetX-88, GetY, 48);
        MSDSetCollisionB(GetX, GetY, 8);
	yield;
	}

}

sub standBy//ʒu
{
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(xIni, yIni,30,8);
	wait(60);
	Concentration01(30);
}

task shotM
{
	SetAction(ACT_SHOT_B,30);
	shot;
	wait(60);
	SetAction(ACT_SHOT_A,90);
	shot4;
	wait(240);
	SpellDraw(7,6000);
	SetAction(ACT_SHOT_A,6000);
	shot2;
	wait(90);
	shot3;

task shot4
{
let X=GetClipMinX+8;
let Y=GetCenterY;
loop(3)
{
	loop(15)
	{
		CreateShot01(X+rand(-8,8),Y+rand(-8,8),rand(1.5,3),90,9,10);
		CreateShot01(GetCenterX*2-X,Y,rand(1.5,3),90,9,10);
	Y-=2;
	X+=26;
	wait(1);
	}
	loop(15)
	{
		CreateShot01(X+rand(-8,8),Y+rand(-8,8),rand(1.5,3),90,9,10);
		CreateShot01(GetCenterX*2-X,Y,rand(1.5,3),90,9,10);
	Y-=2;
	X-=26;
	wait(1);
	}
}


}

task shot3
{

loop
{
        CreateEnemyFromScript("Familiar3", GetX, GetY,
                              0, 0, 1);
	wait(300);
        CreateEnemyFromScript("Familiar3", GetX, GetY,
                              0, 0, -1);
	wait(300);
}

}

task shot2
{
let waittime=60;
let count=0;
loop
{
	ascent(let i in 0..20)
	{
	ascent(let j in 0..5)
	{
		CreateShot01(GetX,GetY,1.4+0.4*j,GetAngleToPlayer+18*i,41,15);
	}
	}
	wait(waittime);
/*
	if(count==5)
	{
	waittime=30;
	}
*/
	count+=1;
}

}

task shot
{
let X=GetX+75;
let X2=GetX-75;
let Y=GetY-20;
let angle1;
let angle2;
let anglecicle=0;
loop
{
	angle1=atan2(GetPlayerY-Y,GetPlayerX-X)+5*cos(anglecicle);
	angle2=atan2(GetPlayerY-Y,GetPlayerX-X2)+5*cos(180+anglecicle);
	if(!OnBomb)
	{
	ascent(let i in -2..2)
	{
		CreateShot01(X,Y,10,angle1+i*72+36,46,5);
		CreateShot01(X2,Y,10,angle2+i*72+36,46,5);
	}
	}
	anglecicle+=12;
	wait(2);
}
}


}
///////////////////////////////////////////////////////
task shotE
{
let waittime=5;
	SetAction(ACT_SHOT_B,30);
	shot;
	wait(60);
	SetAction(ACT_SHOT_A,180);
	summon;
	wait(300);
	SpellDraw(8,6000);
	SetAction(ACT_SHOT_A,6000);
	shot3;

task shot
{
let X=GetX+75;
let X2=GetX-75;
let Y=GetY-20;
let angle1;
let angle2;
let anglecicle=0;
loop
{
	angle1=atan2(GetPlayerY-Y,GetPlayerX-X)+5*cos(anglecicle);
	angle2=atan2(GetPlayerY-Y,GetPlayerX-X2)+5*cos(180+anglecicle);
	if(!OnBomb)
	{
	ascent(let i in 0..5)
	{
		CreateShot01(X,Y,10,angle1+i*72+36,46,5);
		CreateShot01(X2,Y,10,angle2+i*72+36,46,5);
	}
	}
	anglecicle+=12;
	wait(2);
}
}

task shot3
{
let angle=atan2(GetClipMaxY-GetY,GetClipMaxX-GetX);

loop
{
        CreateEnemyFromScript("Familiar4", GetX, GetY,
                              0, waittime, 1);

	wait(195);

        CreateEnemyFromScript("Familiar4", GetX, GetY,
                              0, waittime, -1);


	wait(195);
/*
	if(waittime>3)
	{
	waittime-=1;	
	}
*/
}

}

task shot2
{
let X=GetX+65;
let X2=GetX-65;
let Y=GetY-25;
let angle=GetAngleToPlayer+rand(-5,5);
	ascent(let i in -12..12)
	{
		ascent(let j in -6..6)
		{
			CreateShot01(X,Y,3+0.25*j,angle+i*5,9,5);
		}
	wait(1);
	}
	wait(30);
	angle=GetAngleToPlayer+rand(-5,5);
	ascent(let i in -12..12)
	{
		ascent(let j in -6..8)
		{
			CreateShot01(X2,Y,3+0.25*j,angle-i*5,9,5);
		}
	wait(1);
	}
	wait(30);
	angle=GetAngleToPlayer+rand(-5,5);
	ascent(let i in -12..12)
	{
		ascent(let j in -6..10)
		{
			CreateShot01(X,Y,3+0.25*j,angle+i*5,9,5);
		}
	wait(1);
	}
	wait(30);
	angle=GetAngleToPlayer+rand(-5,5);
	ascent(let i in -12..12)
	{
		ascent(let j in -6..15)
		{
			CreateShot01(X2,Y,3+0.25*j,angle-i*5,9,5);
		}
	wait(1);
	}
}

task summon
{
loop(3)
{
        CreateEnemyFromScript("Familiar", GetX+80*cos(GetAngleToPlayer+90), GetY+80*sin(GetAngleToPlayer+90),
                              0, GetAngleToPlayer, 1);
        CreateEnemyFromScript("Familiar", GetX-80*cos(GetAngleToPlayer+90), GetY-80*sin(GetAngleToPlayer+90),
                              0, GetAngleToPlayer, -1);

        CreateEnemyFromScript("Familiar", GetX, GetY,
                              0, GetAngleToPlayer, -1);
wait(60);
}
}

}
/////////////////////////////////////////////////////////////////
task shotA
{
	SetAction(ACT_SHOT_B,30);
	shot;
	wait(60);
	SetAction(ACT_SHOT_A,180);
	shot2;
	wait(180);
	SpellDraw(9,6000);
	SetAction(ACT_SHOT_A,6000);
	summon;
	wait(180);
	shot3;

task shot3
{
	shot4(1);
	wait(10);
	shot4(2);
	wait(10);
	shot4(3);
	wait(10);
	shot4(4);
	wait(10);
	shot4(5);
}

task shot4(num)
{
	loop
	{
		CreateShot01(rand(GetClipMinX+((GetClipMaxX-GetClipMinX)*(num-1))/5,GetClipMinX+(GetClipMaxX-GetClipMinX)*num/5),GetClipMinY,rand(1,2.5),rand(88,92),9,5);
		wait(5);
	}
}

task shot
{
let X=GetX+75;
let X2=GetX-75;
let Y=GetY-20;
let angle1;
let angle2;
let anglecicle=0;
loop
{
	angle1=atan2(GetPlayerY-Y,GetPlayerX-X)+5*cos(anglecicle);
	angle2=atan2(GetPlayerY-Y,GetPlayerX-X2)+5*cos(180+anglecicle);
	if(!OnBomb)
	{
	ascent(let i in 0..5)
	{
		CreateShot01(X,Y,10,angle1+i*72+36,46,5);
		CreateShot01(X2,Y,10,angle2+i*72+36,46,5);
	}
	}
	anglecicle+=12;
	wait(2);
}
}

task shot2
{
let X=GetX+65;
let X2=GetX-65;
let Y=GetY-25;
	let angle=atan2(GetPlayerY-Y,GetPlayerX-X)+rand(-5,5);
	ascent(let i in -8..8)
	{
		ascent(let j in -3..6)
		{
			CreateShot01(X,Y,3+0.25*j,angle+i*5,9,5);
		}
	wait(1);
	}
	wait(30);
	angle=atan2(GetPlayerY-Y,GetPlayerX-X2)+rand(-5,5);
	ascent(let i in -8..8)
	{
		ascent(let j in -4..8)
		{
			CreateShot01(X2,Y,3+0.25*j,angle-i*5,9,5);
		}
	wait(1);
	}
	wait(30);
	angle=atan2(GetPlayerY-Y,GetPlayerX-X)+rand(-5,5);
	ascent(let i in -9..9)
	{
		ascent(let j in -5..10)
		{
			CreateShot01(X,Y,3+0.25*j,angle+i*5,9,5);
		}
	wait(1);
	}
	wait(30);
	angle=atan2(GetPlayerY-Y,GetPlayerX-X2)+rand(-5,5);
	ascent(let i in -10..10)
	{
		ascent(let j in -6..15)
		{
			CreateShot01(X2,Y,3+0.25*j,angle-i*5,9,5);
		}
	wait(1);
	}
}

task summon
{
loop
{
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, GetAngleToPlayer, 0);
	wait(10);
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, GetAngleToPlayer, 1);
	wait(10);
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, GetAngleToPlayer, 2);
	wait(10);
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, GetAngleToPlayer, 3);
	wait(10);
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, GetAngleToPlayer, 4);
wait(300);
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, GetAngleToPlayer, 0.5);
	wait(10);
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, GetAngleToPlayer, 1.5);
	wait(10);
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, GetAngleToPlayer, 2.5);
	wait(10);
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, GetAngleToPlayer, 3.5);
wait(300);
}
}

}



/////////////////////////////////////////////////////////////////////////////////////////////////////////////
	task Wing{
		let lifetime=30;
		let speed=5.5;
		if(GetCommonDataDefault("LightMode_SpecialEffect",0)==1){lifetime=15;speed=11;}
		let angle=-90;
		loop{
			ascent(j in 0..120){
				WingPart(GetX,GetY,angle+70+5*sin(3*j),lifetime,speed);
				WingPart(GetX,GetY,angle-70-5*sin(3*j),lifetime,speed);

				WingPart(GetX,GetY,angle+90+5*sin(3*j),lifetime*3/4,speed);
				WingPart(GetX,GetY,angle-90-5*sin(3*j),lifetime*3/4,speed);

				WingPart(GetX+20*cos(angle),GetY+20*sin(angle),angle+70+5*sin(3*j),lifetime*5/4,speed);
				WingPart(GetX+20*cos(angle),GetY+20*sin(angle),angle-70-5*sin(3*j),lifetime*5/4,speed);

				WingPart(GetX,GetY,angle+105+5*sin(3*j),lifetime/2,speed);
				WingPart(GetX,GetY,angle-105-5*sin(3*j),lifetime/2,speed);

				WingPart(GetX,GetY,angle+165-1*sin(6*j),lifetime*5/12,speed);
				WingPart(GetX,GetY,angle+180-1*sin(6*j),lifetime/2,speed);
				WingPart(GetX,GetY,angle-165-1*sin(6*j),lifetime*5/12,speed);

			//	HeadPart(GetX,GetY,angle-1*sin(6*j),lifetime*2,speed/2);
				yield;
				}
			}
		}

	task WingPart(let x,let y,let angle,let lifetime,let speed){
		function randrect
		{
			return(rand(-8,8));
		}
		let WingUV=[0,0,48,48];
		let WingXY=[-24+randrect,-24+randrect,24+randrect,24+randrect];
		let obj= Obj_Create(OBJ_EFFECT);
		let scale=0.5;
		let r=0;
		Obj_SetX(obj, x+r*cos(angle));
		Obj_SetY(obj, y+r*sin(angle));
        	ObjEffect_SetTexture(obj,GetCurrentScriptDirectory~"..\img\CircleEffect.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_SetScale(obj, scale,scale);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0,WingXY[0],WingXY[1]);
		ObjEffect_SetVertexXY(obj, 1,WingXY[0],WingXY[3]);
		ObjEffect_SetVertexXY(obj, 2,WingXY[2],WingXY[1]);
		ObjEffect_SetVertexXY(obj, 3,WingXY[2],WingXY[3]);
		
		ObjEffect_SetVertexUV(obj, 0, WingUV[0],WingUV[1]);
		ObjEffect_SetVertexUV(obj, 1, WingUV[0],WingUV[3]);
		ObjEffect_SetVertexUV(obj, 2, WingUV[2],WingUV[1]);
		ObjEffect_SetVertexUV(obj, 3, WingUV[2],WingUV[3]);

		let Alpha=255;

		ObjEffect_SetLayer(obj,1);
		Obj_SetSpeed(obj,speed);
		Obj_SetAngle(obj,angle);
		loop(lifetime){
			r+=speed;
			scale-=0.5/lifetime;
			Alpha-=255/lifetime;
			ObjEffect_SetScale(obj, scale,scale);		
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,255,30,30);
			}
   			yield;
			if(GetEnemyLife==0){break;}
			}
		Obj_Delete(obj);
		}


	task HeadPart(let x,let y,let angle,let lifetime,let speed){
		function randrect
		{
			return(rand(-8,8));
		}
		let WingUV=[0,0,48,48];
		let WingXY=[-24+randrect,-24+randrect,24+randrect,24+randrect];
		let obj= Obj_Create(OBJ_EFFECT);
		let scale=0.5;
		let r=0;
		Obj_SetX(obj, x+r*cos(angle));
		Obj_SetY(obj, y+r*sin(angle));
        	ObjEffect_SetTexture(obj,GetCurrentScriptDirectory~"..\img\CircleEffect.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_SetScale(obj, scale,scale);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0,WingXY[0],WingXY[1]);
		ObjEffect_SetVertexXY(obj, 1,WingXY[0],WingXY[3]);
		ObjEffect_SetVertexXY(obj, 2,WingXY[2],WingXY[1]);
		ObjEffect_SetVertexXY(obj, 3,WingXY[2],WingXY[3]);
		
		ObjEffect_SetVertexUV(obj, 0, WingUV[0],WingUV[1]);
		ObjEffect_SetVertexUV(obj, 1, WingUV[0],WingUV[3]);
		ObjEffect_SetVertexUV(obj, 2, WingUV[2],WingUV[1]);
		ObjEffect_SetVertexUV(obj, 3, WingUV[2],WingUV[3]);

		let Alpha=255;

		ObjEffect_SetLayer(obj,1);
		Obj_SetSpeed(obj,speed);
		Obj_SetAngle(obj,angle);
		loop(lifetime){
			r+=speed;
			scale-=0.25/lifetime;
			Alpha-=255/lifetime;
			ObjEffect_SetScale(obj, scale,scale);		
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,255,30,30);
			}
   			yield;
			if(GetEnemyLife==0){break;}
			}
		Obj_Delete(obj);
		}


#include_function ".\..\txt\data.txt"
#include_function ".\..\lib/lib_anime_Mokou.txt"
}


script_enemy Familiar {
    let csd     = GetCurrentScriptDirectory;
    let imgFam  = csd ~ "..\img\familiar.png";
	let num = GetArgument;
    @Initialize {
	SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(50000);
        SetDamageRateEx(100,100,0,0);
        SetTexture(imgFam);
        setGraphic;
	TMain;
    }

    @MainLoop {
    //    SetCollisionA(GetX, GetY, 48);
    //    SetCollisionB(GetX, GetY, 8);
        yield;
    }

    @DrawLoop {
      //  DrawGraphic(GetX, GetY);
    }

        @Finalize
        {
	if(GetEnemyLife>0)
	{
		loop(10)
		{
		FinalizeItemSet(1);
		}
	}
        }

    task TMain {
        yield;
	GetDamege;
	OutDamageRateZero;
	ZakoEnemyLifeDisplay;
	move;
	alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
	case("Moderate")
	{
	//shotM;
	}
	case("Extream")
	{
	shotE;
	}
	case("Apocalypse")
	{
	//shotA;
	}
	ZakoEffect(255,0,0);
    }

task move
{
	let angle=GetAngle;
	let speed=GetSpeed;

	SetAngle(angle);
	loop(180)
	{
	SetSpeed(speed);
	speed+=0.12;
	yield;
	}

	VanishEnemy;

}
/////////////////////////////////////////////////////////
task shotE
{
wait(5);
loop
{
	let angle=rand(0,360);
	CreateShotA(0,GetX,GetY,10);
	SetShotDataA(0,0,0,angle,0,0.01,2,9);
	FireShot(0);
	wait(3);
}
}
////////////////////////////////////////////////////////////

    // OtBbN̐ݒ
sub setGraphic{ SetGraphicRect( 0, 48, 48, 96); }
#include_function ".\..\txt/StageEnemydata.txt"
}


script_enemy Familiar2 {
    let csd     = GetCurrentScriptDirectory;
    let imgFam  = csd ~ "..\img\familiar.png";
	let num = GetArgument;
    @Initialize {
	//SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(350);
        SetDamageRateEx(100,100,0,0);
        SetTexture(imgFam);
        setGraphic;
	TMain;
    }

    @MainLoop {
     //   SetCollisionA(GetX, GetY, 36);
     //   MSDSetCollisionB(GetX, GetY, 8);
        yield;
    }

    @DrawLoop {
      //  DrawGraphic(GetX, GetY);
    }

        @Finalize
        {
	if(GetEnemyLife>0)
	{
		loop(10)
		{
		FinalizeItemSet(1);
		}
	}
        }

    task TMain {
        yield;
	GetDamege;
	OutDamageRateZero;
	ZakoEnemyLifeDisplay;
	move;
	alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
	case("Moderate")
	{
	//shotM;
	}
	case("Extream")
	{
	//shotE;
	}
	case("Apocalypse")
	{
	shotA;
	}
	FamiliarEffect(255,0,0,75);
    }

task move
{
	let X=GetClipMinX+16+(GetClipMaxX+48-GetClipMinX)*num/5;
	let Y=GetClipMaxY+32;

	SetMovePosition03(X, Y,15,6);
	wait(270);
	VanishEnemy;

}

/////////////////////////////////////////////////////////
task shotA
{
wait(90);
Laser;
wait(30);
LaserShot;
}

task LaserShot
{
	loop(12)
	{
	WaveShot(GetX,GetY-32,8,-90,25,10,0,225,5);
	WaveShot(GetX,GetY-32,8,-90,25,10,180,225,5);
	wait(5);
	}
}

task WaveShot(let x, let y, let speed, let angle,
            let amp, let om, let arg, let graphic, let delay) {
    
    let t = 0;
    let px = speed*t;
    let py = amp*sin(om*t + arg);
    let a = amp*om*3.1415926/(180*speed);
    
    //IuWFNge̍쐬
    let obj = Obj_Create(OBJ_SHOT);
    
    //p[^̐ݒ
    Obj_SetPosition(obj, x + px*cos(angle) - py*sin(angle),
                             y + px*sin(angle) + py*cos(angle));
    Obj_SetSpeed(obj, 0);
    Obj_SetAngle(obj, angle + atan(a*cos(om*t + arg)));
    ObjShot_SetGraphic(obj, graphic);
    ObjShot_SetDelay(obj, delay);
	ObjShot_SetBombResist(obj, true);
    loop(delay){ yield; }
	
    while(!Obj_BeDeleted(obj))
    {
        //(px,py)Wł̒ëʒuvZ
        px=speed*t;
        py=amp*sin(om*t + arg);
        //]EsړĎۂ̈ʒu
        Obj_SetPosition(obj, x + px*cos(angle) - py*sin(angle),
                                 y + px*sin(angle) + py*cos(angle));
        //e̕ɂangle𑫂
        Obj_SetAngle(obj, angle + atan(a*cos(om*t + arg)));
        
        t++;
        yield;
    }
}   

task Laser
{
	let length=500;
	let width=80;
	let angle=-90;
        let obj = Obj_Create(OBJ_LASER);
      	ObjLaser_SetSource(obj, false);
        Obj_SetPosition(obj, GetX, GetY);
        ObjLaser_SetLength(obj, length);
        ObjLaser_SetWidth(obj, width);
        Obj_SetAngle(obj,angle);
        ObjShot_SetBombResist(obj, true);
        ObjShot_SetGraphic(obj,153);
	Obj_SetAutoDelete(obj,false);
	ObjShot_SetDelay(obj, 30);
      //  Obj_SetCollisionToPlayer(obj, false);
	loop(30)
	{
		Obj_SetPosition(obj, GetX, GetY);
		yield;
	}
	wait(120);
	loop(30)
	{
		ObjLaser_SetWidth(obj, width);
		width-=80/30;
		yield;
	}
	Obj_Delete(obj);
}

task FamiliarEffect(R,G,B,frame)
{
	//FamiliarEffect0(R,G,B);
loop(frame)
{
	FamiliarEffect1(R,G,B);
yield;
}
}

task FamiliarEffect0(R,G,B)
{
		let scax=1.0;
		let scay=1.0;
		let angle=0;
		let Xangle=-90;
		let Yangle=-90;	
		let Zangle=0;
		let RotateAngle=3;
		let alpha=100;
  		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,GetCurrentScriptDirectory~"..\img\CircleEffect.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -24, -24);
		ObjEffect_SetVertexXY(obj, 1,  24, -24);
		ObjEffect_SetVertexXY(obj, 2,  24,  24);
		ObjEffect_SetVertexXY(obj, 3, -24,  24);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  48, 0);
		ObjEffect_SetVertexUV(obj, 2, 48,  48);
		ObjEffect_SetVertexUV(obj, 3, 0, 48);

			ascent(let i in 0..4)
			{
			ObjEffect_SetVertexColor(obj,i,alpha,R,G,B);
			}

		ObjEffect_SetScale(obj, scax,scay);
		loop
		{
		Obj_SetPosition(obj,GetX,GetY);
			yield;
		}
}


task FamiliarEffect1(R,G,B)
{
		let randrect=5;
		let scax=1.0;
		let scay=1.0;
		let angle=0;
		let Xangle=-90;
		let Yangle=-90;	
		let Zangle=0;
		let RotateAngle=3;
		let alpha=50;
  		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,GetCurrentScriptDirectory~"..\img\CircleEffect.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -24+rand(-randrect,randrect), -24+rand(-randrect,randrect));
		ObjEffect_SetVertexXY(obj, 1,  24+rand(-randrect,randrect), -24+rand(-randrect,randrect));
		ObjEffect_SetVertexXY(obj, 2,  24+rand(-randrect,randrect),  24+rand(-randrect,randrect));
		ObjEffect_SetVertexXY(obj, 3, -24+rand(-randrect,randrect),  24+rand(-randrect,randrect));
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  48, 0);
		ObjEffect_SetVertexUV(obj, 2, 48,  48);
		ObjEffect_SetVertexUV(obj, 3, 0, 48);


		Obj_SetPosition(obj,GetX,GetY);
		ObjEffect_SetScale(obj, scax,scay);
		Obj_SetSpeed(obj,1);
		Obj_SetAngle(obj,-90);
		loop(5)
		{
			ascent(let i in 0..4)
			{
			ObjEffect_SetVertexColor(obj,i,alpha,R,G,B);
			}
			ObjEffect_SetScale(obj, scax,scay);
			scax+=0.3/10;
			scay+=0.3/10;
			alpha-=50/10;
			yield;
		}
		Obj_Delete(obj);
}
////////////////////////////////////////////////////////////

    // OtBbN̐ݒ
sub setGraphic{ SetGraphicRect( 0, 48, 48, 96); }
#include_function ".\..\txt/StageEnemydata.txt"
}


script_enemy Familiar3 {
    let csd     = GetCurrentScriptDirectory;
    let imgFam  = csd ~ "..\img\familiar.png";
	let num = GetArgument;
    @Initialize {
	//SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(50000);
        SetDamageRateEx(100,100,0,0);
        SetTexture(imgFam);
        setGraphic;
	TMain;
    }

    @MainLoop {
    //    SetCollisionA(GetX, GetY, 48);
    //   SetCollisionB(GetX, GetY, 8);
        yield;
    }

    @DrawLoop {
      //  DrawGraphic(GetX, GetY);
    }

        @Finalize
        {
	if(GetEnemyLife>0)
	{
		loop(10)
		{
		FinalizeItemSet(1);
		}
	}
        }

    task TMain {
        yield;
	GetDamege;
	OutDamageRateZero;
	ZakoEnemyLifeDisplay;
	move;
	shotM;
	ZakoEffect(255,0,0);
    }

task move
{
	let X=GetClipMaxX;
	let Y=GetClipMaxY;
	if(num>0)
	{
		X=GetClipMaxX;
	}
	else
	{
		X=GetClipMinX;
	}
	SetMovePosition02(X,Y,59);
	wait(60);
	SetSpeed(8);
	SetAngle(270);
	wait(120);
	VanishEnemy;

}
/////////////////////////////////////////////////////////
task shotM
{
wait(60);
loop(11)
{
	let angle=GetAngleToPlayer;
	ascent(let i in 0..12)
	{
		CreateShot01(GetX,GetY,3,angle+i*30,9,5);
	}
	wait(5);
}
}
////////////////////////////////////////////////////////////

    // OtBbN̐ݒ
sub setGraphic{ SetGraphicRect( 0, 48, 48, 96); }
#include_function ".\..\txt/StageEnemydata.txt"
}

script_enemy Familiar4 {
    let csd     = GetCurrentScriptDirectory;
    let imgFam  = csd ~ "..\img\familiar.png";
	let num = GetArgument;
	let waittime=GetAngle;
    @Initialize {
	//SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(50000);
        SetDamageRateEx(100,100,0,0);
        SetTexture(imgFam);
        setGraphic;
	TMain;
    }

    @MainLoop {
    //    SetCollisionA(GetX, GetY, 48);
    //    SetCollisionB(GetX, GetY, 8);
        yield;
    }

    @DrawLoop {
      //  DrawGraphic(GetX, GetY);
    }

        @Finalize
        {
	if(GetEnemyLife>0)
	{
		loop(10)
		{
		FinalizeItemSet(1);
		}
	}
        }

    task TMain {
        yield;
	GetDamege;
	OutDamageRateZero;
	ZakoEnemyLifeDisplay;
	move;
	shotM;
	ZakoEffect(255,0,0);
    }

task move
{
	let X=GetClipMaxX;
	let Y=GetClipMaxY;
	if(num>0)
	{
		X=GetClipMaxX;
	}
	else
	{
		X=GetClipMinX;
	}
	SetMovePosition02(X,Y,60);
	wait(60);
	if(num==1)
	{
	SetMovePosition02(GetClipMaxX,GetClipMinY,60);
	}
	else
	{
	SetMovePosition02(GetClipMinX,GetClipMinY,60);
	}
	wait(60);
	if(num==1)
	{
	SetMovePosition02(GetClipMinX,GetClipMinY,60);
	}
	else
	{
	SetMovePosition02(GetClipMaxX,GetClipMinY,60);
	}
	wait(60);
	if(num==1)
	{
	SetMovePosition02(GetClipMinX,GetClipMaxY,60);
	}
	else
	{
	SetMovePosition02(GetClipMaxX,GetClipMaxY,60);
	}
	wait(61);
	SetSpeed(8);
	SetAngle(90);
	wait(15);
	VanishEnemy;

}
/////////////////////////////////////////////////////////
task shotM
{
wait(60);
	let dir=1;
	let X=GetClipMaxX;
	if(num>0)
	{
		X=GetClipMaxX;
	}
	else
	{
		X=GetClipMinX;
	}
	if(X==GetClipMinX)
	{
		dir=-1;
	}
	let Y=GetClipMaxY;
	let angle=atan2(GetPlayerY-Y,GetPlayerX-X);
	loop(60/waittime)
	{
		angle=GetAngleToPlayer;
		ascent(let i in 0..12)
		{
			CreateShot01(GetX,GetY,3,angle+i*30,9,5);
		}
		CreateShot01(GetX,GetY,rand(1,1.5),rand(175,185),33,5);
		CreateShot01(GetX,GetY+20,rand(1,1.5),rand(170,190),33,5);
		wait(waittime);
	}
	loop(60/waittime)
	{
		angle=GetAngleToPlayer;
		ascent(let i in 0..12)
		{
			CreateShot01(GetX,GetY,3,angle+i*30,9,5);
		}
		CreateShot01(GetX,GetY,rand(1,1.5),rand(85,95),33,5);
		CreateShot01(GetX+20,GetY,rand(1,1.5),rand(80,100),33,5);
		wait(waittime);
	}
	loop(60/waittime)
	{
		angle=GetAngleToPlayer;
		ascent(let i in 0..12)
		{
			CreateShot01(GetX,GetY,3,angle+i*30,9,5);
		}
		CreateShot01(GetX,GetY,rand(1,1.5),rand(-5,5),33,5);
		CreateShot01(GetX,GetY+20,rand(1,1.5),rand(-10,10),33,5);
		wait(waittime);
	}
}
////////////////////////////////////////////////////////////

    // OtBbN̐ݒ
sub setGraphic{ SetGraphicRect( 0, 48, 48, 96); }
#include_function ".\..\txt/StageEnemydata.txt"
}
#include_script ".\..\txt/EnemyShotData.txt"
